<style scoped>
  .pickinglist >>> .weui-form-preview__hd .weui-form-preview__value {
    font-size: 1.2em;
    padding-right: 20px;
  }
  .sellform {
    background: #e3e3e3;
  }
  .page-infinite-wrapper {
    background: #e3e3e3;
  }
  .sellform >>> .weui-cells {
    margin-top: 0;
    background: #e3e3e3;
  }
  .sellform >>> .weui-loadmore__tips {
    background: #e3e3e3;;
  }
  .sellform >>> .weui-loadmore {
    margin-bottom: 0;
  }
  .weui-form-preview {
    margin: 5px;
    border-radius: 5px;
  }

  .rj-cell-child {
    display: inline-block;
    font-size: 0;
    padding: 5px 15px;
    text-align: left;
  }
  .rj-cell-child.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell-child.minpad{
    padding-right: 10px !important;
  }
  .rj-cell-child label {
    color: #333;
    font-size: 14px;
  }
  .rj-cell-child span {
    padding-left: 20px;
    font-size: 14px;
    color: #333;
  }
  .rj-cell-child .tip {
    font-size: 16px;
    color: #333;
  }
  .rj-cell-child i {
    font-size: 18px;
    font-style: normal;
    color: #333;
  }
  .rj-cell-child-tit {
    background: #eee;
    font-size: 14px;
    padding: 5px 15px;
    border-bottom: 1px solid #ddd;
  }
  .weui-form-preview__ft .weui-form-preview {
    background: #f5f5ef;
  }
  .weui-form-preview__ft {
    line-height: normal;
  }



  .weui_tab_bd {
    background: #eee;
  }
  .weui-form-preview {
    background-color: #fff;
    margin: 5px;
    border-radius: 5px;
  }
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .weui_navbar {
    white-space: nowrap;
    overflow: scroll;
    display: block !important;
    border-bottom: 1px solid #BCBAB6;
    font-size: 0;
    /*background: #fafafa;*/
  }
  .weui_navbar_item {
    font-size: 14px;
    display: inline-block;
    width: 33.3%;
    padding: 13px 0;
    background: #fff;
    position: relative;
    color: #888;
  }
  .weui_navbar_item.weui_bar_item_on {
    background-color: #f5f5f5;
    color: #00913a;
  }
  .weui_navbar:after {
    border-bottom: 0;
  }
  .weui_navbar_item:after {
    content: " ";
    position: absolute;
    right: 0;
    top: 0;
    width: 1px;
    height: 100%;
    border-right: 1px solid #cccccc;
    color: #cccccc;
    -webkit-transform-origin: 100% 0;
    transform-origin: 100% 0;
    -webkit-transform: scaleX(0.5);
    transform: scaleX(0.5);
    font-size: 10px;
  }
  .weui-panel__bd {
    text-align: left;
  }
  .hoverbar {
    background: #cfd4d6;
    position: relative;
    top:5px;
    left:90%;
    bottom: 100px;
    right: 20px;
    height: 20px;

    width: 20px;
    z-index: 100;
    font-size: 15px;
    border-radius: 50%;
    box-shadow: 0px 2px 3px rgba(100, 100, 100, 0.5);
    color: #fff;
    text-align:center;
  }

  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .weui-loadmore_line .weui-loadmore__tips {
    background-color: #eee;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
    width: 44%;
    display: inline-block;
    padding: 5px 3%;
    text-align: right;
  }
  .rj-cell span {
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 50%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cells {
    margin-top: 0;
  }
  .weui-cells_form {
    background: #fbfbfb;
  }
  .weui-cell {
    background: #fff;
  }
  #acts span {
    font-size: 14px;
  }
  .halfbtn {
    display: inline-block;
    width: 49%;
  }
  .weui-label{
    /*width: 130px;*/
    text-align: left;
  }

  .weui-select {
    height: auto;
    line-height: normal;
  }
  *{
    list-style:none;
  }
  /*body{*/

  /*}*/
  .weui-cell_select {
    padding: 10px 15px;
  }
  .weui-cells__title {
    text-align: left;
  }
  .hide {
    display: none;
  }
  #acts {
    font-size: 0;
  }
  #acts span {
    font-size: 14px;
  }
  input.time {
    border: none;
    font-size: 16px;
    padding-left: 10px;
  }
  .delsty {
    position: absolute;
    top: 2px;
    right: 0px;
    z-index: 1000;
    /*height: 20px;*/
    /*width: 20px;*/
    /*z-index: 100;*/
    /*font-size: 15px;*/
    /*border-radius: 50%;*/
    /*box-shadow: 0px 2px 3px rgba(100, 100, 100, 0.5);*/
    /*color: #fff;*/
    /*text-align: center;*/
  }

</style>

<template>
  <div class="pickinglist">
    <SearchBar @doSearch="doSearch" />
    <div class="weui_tab">
      <div class="weui_navbar order-tabhd">
        <a class="weui_navbar_item" v-for="(item, index) in tabTitles" :key="item.guid" :style="'width:' + tabWidth" :class="{ weui_bar_item_on: postParams.status == item.stats }" href="javaScript:;" @click="switchStatus(item.stats)">{{item.name}}</a>
        <!--        <a class="weui_navbar_item" :class="{ weui_bar_item_on: postParams.status == 1 }" href="javaScript:;" @click="switchStatus(1)">待质检</a>-->
<!--        <a class="weui_navbar_item " :class="{ weui_bar_item_on: postParams.status == 2 }" href="javaScript:;" @click="switchStatus(2)">待入库</a>-->
<!--        <a class="weui_navbar_item " :class="{ weui_bar_item_on: postParams.status == 3 }" href="javaScript:;" @click="switchStatus(3)">已入库</a>-->
      </div>
      <div class="weui_tab_bd" style="background-color: #fff">
        <div class="page-infinite-wrapper" ref="wrapper" :style="{ height: wrapperHeight + 'px' }" >
          <mescroll-vue ref="mescroll" id="wrapper" :down="mescrollDown" :up="mescrollUp" @init="mescrollInit">
            <div class="weui-form-preview" v-for="(item, index) in data" :key="item.guid" :ref="item.guid">
              <div class="weui-form-preview__hd" @click="viewItem(item.guid)">
                <label class="weui-form-preview__label">编号</label>
                <em class="weui-form-preview__value">{{item.code}}</em>
              </div>
              <div class="weui-form-preview__bd">
                <div class="weui-form-preview__item">
                  <label class="weui-form-preview__label">生产计划</label>
                  <span class="weui-form-preview__value">{{item.planname}} [{{cutDate(item.planstart)}}]</span>
                </div>
                <div class="weui-form-preview__item">
                  <label class="weui-form-preview__label">领料单</label>
                  <span class="weui-form-preview__value">{{item.pickcode}}</span>
                </div>
                <div class="weui-form-preview__item">
                  <label class="weui-form-preview__label">货品所属</label>
                  <span class="weui-form-preview__value">{{item.orgname}}</span>
                </div>
                <div class="weui-form-preview__item">
                  <label class="weui-form-preview__label">所在班组</label>
                  <span class="weui-form-preview__value">{{item.department}}</span>
                </div>
                <div class="weui-form-preview__item">
                  <label class="weui-form-preview__label">公司</label>
                  <span class="weui-form-preview__value">{{item.orgname}}</span>
                </div>
                <div class="weui-form-preview__item">
                  <label class="weui-form-preview__label">库房</label>
                  <span class="weui-form-preview__value">{{item.strname}}</span>
                </div>
                <div class="weui-form-preview__item">
                  <label class="weui-form-preview__label">库房类型</label>
                  <span class="weui-form-preview__value">{{item.type == 1 ? '产成品库' : '次品库'}}</span>
                </div>
                <div class="weui-form-preview__item">
                  <label class="weui-form-preview__label">申请时间</label>
                  <span class="weui-form-preview__value">{{item.createtime}}</span>
                </div>
                <div class="weui-form-preview__item">
                  <label class="weui-form-preview__label">申请人</label>
                  <span class="weui-form-preview__value">{{item.operator}}</span>
                </div>


                <div class="weui-form-preview__item" v-show="item.status ==2">
                  <label class="weui-form-preview__label">质检结果</label>
                  <span class="weui-form-preview__value"> {{item.type == 1 ? '合格' : '不合格'}}</span>
                </div>

                <div class="weui-form-preview__item" v-show="item.status ==2">
                  <label class="weui-form-preview__label">质检人</label>
                  <span class="weui-form-preview__value">{{item.qaoperatorname}}</span>
                </div>

                <div class="weui-form-preview__item" v-show="item.status ==2">
                  <label class="weui-form-preview__label">质检时间</label>
                  <span class="weui-form-preview__value">{{item.qacreatedate }}</span>
                </div>



              </div>
              <div class="weui-form-preview__ft olist">
                <!--                <div class="weui-panel__hd"></div>-->
                <div class="weui-panel__bd only" :data-pickid="item.pickcode">
                  <form v-if="editing && item.guid == applyid" id="formid">
                    <ApplySrItem2 v-for="(row, index) in oldItems" :key="row.guid" :itemNo="row" :no="index" :type="type" @doDelItem="doDelOldItem(index, row.guid)"></ApplySrItem2>
                    <ApplySrItem3 v-for="(row, index) in oitems" :key="index" :itemNo="oldItems.length + index" :isLast="index +1 == oitems.length" :products="products" :type="type" @doAddItem="addItem(row + 1)" @doDelItem="doDelItem"></ApplySrItem3>
                    <div class="weui-btn-area">
                      <a class="weui-btn weui-btn_primary halfbtn subbtn"  href="javascript:" @click="doEdit(item.guid)">提交</a>
                      <a class="weui-btn weui-btn_primary halfbtn"  href="javascript:" @click="doCancelEdit" id="sub">取消</a>
                    </div>
                  </form>
                  <div class="weui-form-preview" v-if="!(editing && item.guid == applyid)" v-for="(product, index) in item.items" :key="product.guid">
                    <div class="rj-cell-child-tit">货品明细 {{index+1}}
                        <p id="acts" style="float: right;color: #1aad19;" v-if="index == 0 && item.status == 1 && item.operatorid == userid">
                          <span @click="editItems(item.items, item.pickinglistid, item.guid)" style="padding-right: 5px;">调整</span>
                        </p>
                    </div>
                    <div class="rj-cell-child max">
                      <label>产&nbsp;&nbsp;&nbsp;品：</label><span>{{product.product}}</span>
                    </div>
                    <div class="rj-cell-child" v-if="item.status == 3">
                      <label>重&nbsp;&nbsp;&nbsp;量：</label><span>{{product.weight}} 吨</span>
                    </div>
                    <div class="rj-cell-child" v-if="product.spename">
                      <label>规&nbsp;&nbsp;&nbsp;格：</label><span>{{product.spename}}</span>
                    </div>
                    <div class="rj-cell-child" v-if="item.status == 3">
                      <label>库&nbsp;&nbsp;&nbsp;间：</label><span>{{product.housename}}</span>
                    </div>
                  </div>
                </div>
              </div>

              <div class="weui-form-preview__ft" style="line-height: 50px;">


<!--                <a class="weui-form-preview__btn weui-form-preview__btn_primary" href="javascript:" v-show="permission.storperms && item.status == 2" @click="doAct('FeedStoreRm', item.guid)" >入库</a>-->
<!--                <a class="weui-form-preview__btn weui-form-preview__btn_primary weui-delbtn" href="javascript:" v-show="item.operatorid == userid && item.status <= 2" @click="delItem(item.guid)" >删除</a>-->
<!--                <a class="weui-form-preview__btn weui-form-preview__btn_primary" href="javascript:" v-show="permission.permss.scopetype ==1  && item.status == 1 && permission.srguid == item.srguid && permission.permission == 18  " @click="doAct('FeedStoreRm', item.guid)" >入库</a>-->
<!--                <a class="weui-form-preview__btn weui-form-preview__btn_primary" href="javascript:" v-show="permission.permss.scopetype ==1  && item.status == 2 && permission.srguid == item.srguid && permission.permission == 4  " @click="doAct('FeedStoreRm', item.guid)" >入库</a>-->
<!--                <a class="weui-form-preview__btn weui-form-preview__btn_primary weui-delbtn" href="javascript:" v-show="permission.permss.scopetype ==1  && item.status == 2 && permission.srguid == item.srguid && permission.permission == 4 && item.operatorid == userid && item.status <= 2" @click="delItem(item.guid)" >删除</a>-->

<!--              <div class="weui-form-preview__ft" style="line-height: 50px;">-->
<!--                <template v-for="(permission, index) in permissions">-->
<!--                  <a class="weui-form-preview__btn weui-form-preview__btn_primary" href="javascript:" v-show="permission.permss.scopetype ==1 && permission.srguid == item.srguid && permission.permission == 18  && item.status == 1" @click="toQaform('FeedStoreRm', item.guid)" >质检</a>-->
<!--                  <a class="weui-form-preview__btn weui-form-preview__btn_primary" href="javascript:" v-show="permission.permss.scopetype ==1 && permission.srguid == item.srguid && permission.permission == 4 && item.status == 2" @click="doAct('FeedStoreRm', item.guid)" >入库</a>-->
<!--                </template>-->
<!--                <a class="weui-form-preview__btn weui-form-preview__btn_primary weui-delbtn" href="javascript:" v-show="item.operatorid == userid && item.status <= 2" @click="delItem(item.guid)" >删除</a>-->
<!--              </div>-->
                <a class="weui-form-preview__btn weui-form-preview__btn_primary" v-for="(node, index) in item.nodes" :key="node.guid" href="javascript:" v-if="filterPerm(node.permission, item.srguid, item.departid, item.operatorid)" @click="doAct(node.operate, item.guid, node.guid, node.name, node.annex)" >{{node.name}}</a>
              </div>
              </div>
          </mescroll-vue>
        </div>
      </div>
    </div>
  </div>
</template>

<script type="text/babel">
  import MescrollVue from 'mescroll.js/mescroll.vue'
  import SearchBar from '../common/SearchBar'
  import ApplySrItem2 from "./ApplySrItem2";
  import ApplySrItem3 from "./ApplySrItem3";

  export default {
    name: 'ApplyStoreRmList',
    components: {SearchBar, MescrollVue, ApplySrItem2, ApplySrItem3},
    data() {
      return {
        openid: localStorage.openid,
        userid: localStorage.userid,
        permission: {},
        permissions:[],
        postParams: {
          status: 1
        },
        mescroll: null, // mescroll实例对象
        mescrollDown: {},
        mescrollUp: { // 上拉加载的配置.
          callback: this.upCallback, // 上拉回调,此处简写; 相当于 callback: function(page, mescroll) { }
          page: {
            num: 0, //当前页 默认0,回调之前会加1; 即callback(page)会从1开始
            //size: 5 //每页数据条数,默认10
          },
          htmlNodata: '<p class="upwarp-nodata">-- 我是有底线的 --</p>',
          noMoreSize: 1,
          empty: {
            warpId: "wrapper", //父布局的id (1.3.5版本支持传入dom元素)
            tip: "暂无相关数据~" //提示
          }
        },
        wrapperHeight: 0,
        data: [],
        type: 1,
        products: [],
        oitems: [],
        currentProduct: '',
        specifications: [],
        oldItems: [],
        deledOldItemIds: [],
        editing: false,
        applyid: '',
        tabTitles: [],
        tabWidth: '25%',
      }
    },
    created() {
      //从首页进入刷新
      this.$parent.reload();

      window.addEventListener('setItem', ()=> {
        this.openid = localStorage.getItem('openid');
        this.userid = localStorage.getItem('userid');
      })
    },
    mounted() {
      //获取权限
      this.getPermission2();
      //获取tab标签页title
      this.getLabels();
      this.wrapperHeight = document.documentElement.clientHeight - this.$refs.wrapper.getBoundingClientRect().top;

    },
    watch: {
      'currentProduct': function(){
        this.getSpecByPro();
      }
    },
    methods: {
      getLabels: function() {
        this.axios({
          method: 'get',
          params:{flowid:5},
          url: '/produce/Label!getLabels.action?openid=' + localStorage.openid,
        }).then((response) => {
          if (response.data.msg == 'success') {
            this.$nextTick(() => {
              this.tabTitles = response.data.labels;
              this.tabWidth = (100 / response.data.labels.length) + '%';
            })
          } else {
            this.toastError("系统错误");
          }
        })
      },
      filterPerm: function(perm, roomid, departid, operatorid) {
        let status = false;
        if (perm == 0) {
          status = this.userid == operatorid;
        } else {
          let permissions = this.permissions;
          if (permissions.length == 0) return;
          for (let i=0; i<permissions.length; i++) {
            if (perm == permissions[i].permission) {
              if (permissions[i].permss.scopetype == 1) {
                if (permissions[i].srguid == roomid) {
                  status = true;
                } else {
                  status = status == true ? true :false;
                }
              } else if (permissions[i].permss.scopetype == 2) {
                if (permissions[i].departid == departid) {
                  status = true;
                } else {
                  status = status == true ? true :false;
                }
              } else if (permissions[i].permss.scopetype == 3) {
                if (permissions[i].srguid == roomid && permissions[i].departid == departid) {
                  status = true;
                } else {
                  status = status == true ? true :false;
                }
              } else if (permissions[i].permss.scopetype == 4) {
                status = true;
              } else {
                status = true;
              }
              //return status;

            }
          }

        }
        return status;
      },
      doEdit: function(guid) {
        if (!this.checkEmy('product')) {
          this.toastText('产品不能为空！');
          return false;
        } else if (!this.checkEmy('spec')) {
          this.toastText('规格不能为空！');
          return false;
        } else if (!this.checkProduct()) {
          this.toastText('货品明细产品重复！')
          return false;
        }

        //防止重复提交
        $('.subbtn').attr("disabled",true).css("pointer-events","none");

        let postData = this.serialize2Obj($("#formid").serializeArray());
        postData.whinapplyid = guid;
        postData.delids = this.deledOldItemIds.join(',');
        console.log('postData:', postData)
        this.axios({
          method: 'post',
          url: '/produce/Whinapply!update.action',
          params: postData
        }).then((response) => {
          //恢复提交按钮可点击
          $('.subbtn').attr('disabled', false).css("pointer-events","auto");

          if (response.data.msg == 'success') {
            this.toastSuccess('调整成功！');
            this.doCancelEdit();
            this.getPageData();
          } else if (response.data.msg == 'canotopt') {
            this.toastError('不允许的操作！');
            this.doCancelEdit();
          } else {
            this.toastError("系统错误");
          }

        }).catch(error => {
          //恢复提交按钮可点击
          $('.subbtn').attr('disabled', false).css("pointer-events","auto");
        })
      },
      doCancelEdit: function() {
        this.oldItems = [];
        this.oitems = [];
        this.deledOldItemIds = [];
        this.editing = false;
      },
      editItems: function(items, pickid, guid) {
        this.applyid = guid;
        this.oldItems = items;
        this.oitems = [items.length];
        this.editing = true;
        this.getApplyInfo(pickid);
      },
      getApplyInfo: function(guid) {
        this.axios({
          method: 'get',
          url: '/produce/Whinapply!getApplyInfo.action',
          params: {pickinglistid: guid}
        }).then((response) => {
          if (response.data.msg == 'success') {
            let data = response.data;
            this.products = data.products;
          } else {
            this.toastError("系统错误");
          }

        })
      },
      getSpecByPro: function() {
        this.axios({
          method: 'get',
          url: '/produce/Whinapply!getSpeByproduct.action',
          params: {productid: this.currentProduct}
        }).then((response) => {
          if (response.data.msg == 'success') {
            let data = response.data;
            this.specifications = data.specifications;
          } else {
            this.toastError("系统错误");
          }

        })
      },
      addItem: function(index) {
        if (!this.checkEmy('product')) {
          this.toastText('产品不能为空！');
          return false;
        } else if (!this.checkEmy('spec')) {
          this.toastText('规格不能为空！');
          return false;
        }
        this.oitems.push(index);
      },
      doDelOldItem: function(index, guid) {
        this.oldItems.splice(index, 1);

        this.deledOldItemIds.push(guid);
      },
      doDelItem: function() {
        this.oitems.pop();
      },
      cutDate: function(date) {
        return date.substring(0, 10);
      },
        viewItem: function(guid) {
            this.$router.push({name: 'ViewApplyStoreRmList', query: {id:guid}});
        },
      switchStatus: function (sta) {
        this.postParams.status = sta;
        this.getPageData("reset");
      },
      getPermission2: function() {
        this.axios({
          method: 'get',
          url: '/produce/OperatorPermission!getOperPerm.action?openid=' + localStorage.openid + '&opttype=2',
        }).then((response) => {
          if (response.data.msg == 'success') {
            this.$nextTick(() => {
              console.log('permissions:', response.data.permission);
              this.permissions = response.data.permission;
            })
          } else {
            this.toastError("系统错误");
          }

        })
      },
      mescrollInit (mescroll) {
        this.mescroll = mescroll  // 如果this.mescroll对象没有使用到,则mescrollInit可以不用配置
      },
      upCallback (page, mescroll) {
        console.log('in upCallback')
        this.postParams.pageNo = page.num;
        this.postParams.functiontype = 2;
        // 联网请求
        this.axios({
          method: 'get',
          url: '/produce/Whinapply!page.action?openid=' + localStorage.openid,
          params: this.postParams
        }).then((response) => {
          console.log('response:', response.data.pagelist)
          if (response.data.msg == 'success') {
            let res = response.data.pagelist != undefined ? response.data.pagelist : {rows: []};
            // 如果是第一页需手动置空列表
            if (page.num === 1) this.data = []
            // 把请求到的数据添加到列表
            this.data = this.data.concat(res.rows);
            console.log('this.data:', this.data)
            // 数据渲染成功后,隐藏下拉刷新的状态
            this.$nextTick(() => {
              mescroll.endSuccess(res.rows.length)
            })
            //将获取上一访问列表临时页码恢复正常
            if (this.mescrollUp.page.size > 5) {
              this.mescrollUp.page.num = this.$store.state.list.pageNo;
              this.mescrollUp.page.size = 5;
            }
          } else {
            this.toastError("系统错误");
          }

        }).catch((e) => {
          // 联网失败的回调,隐藏下拉刷新和上拉加载的状态;
          mescroll.endErr()
        })
      },
      getPageData: function (type) {
        $('#wrapper').scrollTop(0);
        this.mescroll.resetUpScroll();
      },
      doSearch: function(keywords) {
        this.postParams.search = keywords;
        this.getPageData();
      },
      toQaform: function (guid, nodeid, annex) {
        window.location.href = '/trace/Qaform!index.action?openid='+localStorage.openid+'&orderguid='+guid+'&orderType=3'+'&nodeid=' + nodeid + '&annex=' + annex;
      },
      // doAct: function (name, guid, type = 0) {
      //   if (type == 0) {
      //     this.$router.push({name: name, query: {guid:guid}});
      //   } else {
      //       this.$router.push({name: name, query: {guid:guid, type: type}});
      //   }
      // },
      doAct: function (name, guid, nodeid, actname, annex) {
        if (name == 'qacheck') {
          this.toQaform(guid, nodeid, annex);
        } else {
          let acts = this.$store.state.acts;
          this.$router.push({name: acts[name], query: {guid:guid, nodeid: nodeid, title: actname, annex: annex}});
        }
      },
      delItem: function (guid) {
          var that = this;
          $.confirm("确定删除!", function() {
              that.axios({
                  method: 'post',
                  url: '/produce/Whinapply!delete.action?openid=' + localStorage.openid,
                  params: {whinapplyid: guid}
              }).then((response) => {
                  if (response.data.msg == 'success') {
                      that.$refs[guid][0].remove();
                      this.toastSuccess('删除成功！');
                  } else if (response.data.msg == 'canotdel') {
                      this.toastError('无权删除！');
                  } else {
                      this.toastError("系统错误");
                  }

              })
          }, function() {
              //点击取消后的回调函数
          });



      },
      //判断明细产品是否重复
      checkProduct: function () {
        let parr1 = [];
        let parr2 = [];
        for (let i=0; i<$('.oitem').length; i++) {
          let tempProduct = $('.product').eq(i).val();
          let tempSpec = $('.spec').eq(i).val();
          parr1.push({[tempProduct]: tempSpec});
          parr2.push({[tempProduct]: tempSpec});
        }
        //json数组去重
        for (var i = 0; i < parr2.length; i++) {
          for (var j =i+1; j <parr2.length; ) {
            if (Object.keys(parr2[i])[0] == Object.keys(parr2[j])[0] && Object.values(parr2[i])[0] == Object.values(parr2[j])[0] ) {
              parr2.splice(j, 1);//去除重复的对象；
            }else {
              j++;
            }
          }
        }
        return parr1.length == parr2.length ? true : false;
      }
    },
    activated () {
      //判断是否是返回上一页
      if (this.$store.state.list.reffer != this.$options.name) return;
      //获取上一次访问列表数据
      this.mescrollUp.page.num = 0;
      this.mescrollUp.page.size = this.$store.state.list.pageNo * this.mescrollUp.page.size;
      this.getPageData();
      //定位
      this.$nextTick(function(){
        let position = this.$store.state.list.postion //返回页面取出来
        $('#wrapper').scrollTop(position);
        let status = this.$store.state.list.status;
        this.postParams.status = status;
      })
    },
    beforeRouteLeave(to, from, next){
      let position = $('#wrapper').scrollTop();
      let status = this.postParams.status;
      this.$store.commit('setPosition', position) //离开路由时把位置存起来
      this.$store.commit('setStatus', status)
      this.$store.commit('setPageNo', this.mescrollUp.page.num);
      this.$store.commit('setReffer', this.$options.name);
      next()
    }
  };
</script>
